package edu.cuc.akkaDay01.demo02;

import akka.actor.AbstractActor;
import akka.japi.pf.ReceiveBuilder;
import scala.PartialFunction;
import scala.runtime.BoxedUnit;

/**
 * Created by bingruiqi on 2017/9/10.
 */
public class Greeter extends AbstractActor {
    public static enum Msg {
        GREETER, DONE;
    }

    @Override
    public PartialFunction<Object, BoxedUnit> receive() {
        return ReceiveBuilder.matchEquals(Msg.GREETER, message -> {
            System.out.println(message+"  helloworld");
            sender().tell(Msg.DONE, self());
        }).matchAny(o -> System.out.println("unknow message")).build();
    }
}
